<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <ol>
        <li>111</li>
        <li>222</li>
    </ol>

    <script>
        //创建li标签
        const liObj = document.createElement("li")
        //给li标签加内容
        const textNode = document.createTextNode("哈哈哈")
        liObj.appendChild(textNode)

        console.log(liObj)

        //将创建的li加到ol里面
        const olObj = document.querySelector("ol")
        olObj.appendChild(liObj)
        
        //给创建的li增加属性
        //方式一
        liObj.setAttribute("li","bw1")
        //方式二
        const add = document.createAttribute("id")  //创建一个属性
        add.value="name1"               //给属性赋值
        liObj.setAttributeNode(add)         //将属性添加到li中
    </script>
</body>
</html>